package com.lonty.intelligence.controller;

import com.lonty.intelligence.api.Result;
import com.lonty.intelligence.api.ResultCode;
import com.lonty.intelligence.service.CertificateService;
import com.lonty.intelligence.vo.CertificateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author 陈璇
 * @Date 2020/4/22 9:24
 * @Version 1.0
 */
@RestController
@RequestMapping("app/certificate")
@Validated
@Api(tags = "房产证接口", produces = "application/json")
public class CertificateController {

    @Resource
    private CertificateService certificateService;

    @ApiOperation(value = "保存房产证", httpMethod = "POST")
    @PostMapping("saveCertificate")
    public Result saveCertificate(@ModelAttribute CertificateVo certificateVo){
        return certificateService.saveCertificate(certificateVo);
    }

    @ApiOperation(value = "根据住户ID获取房产信息", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "householdId", value = "住户ID",dataType = "string", paramType = "query", required = true)
    })
    @GetMapping("getCertificateByHouseholdId")
    public Result getCertificateByHouseholdId(String householdId){
        return Result.builder()
                .data(certificateService.getCertificateByHouseholdId(householdId))
                .build();
    }

}
